package foundation.递归;

import java.util.ArrayList;
import java.util.List;

/**
 * @author hang an
 * @since 2025/7/13
 */
public class 字符串全部子序列 {
    private static List<String> res = new ArrayList<>();

    public static void main(String[] args) {
        f("abc".toCharArray(), 0, new StringBuilder());
        res.forEach(System.out::println);
    }

    public static void f(char[] cs, int index, StringBuilder sb) {
        if (index == cs.length) {
            res.add(sb.toString());

        } else {
            f(cs, index + 1, sb.append(cs[index]));
            sb.deleteCharAt(sb.length() - 1);
            f(cs, index + 1, sb);
        }

    }
}
